package com.zlp.mall.modules.oss.controller;



import com.zlp.mall.common.api.R;
import com.zlp.mall.modules.oss.dto.OssCallbackResp;
import com.zlp.mall.modules.oss.dto.OssPolicyResp;
import com.zlp.mall.modules.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


@RestController
@Api(value = "OssController", tags = "Oss管理")
@RequestMapping("/aliyun/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    @ApiOperation(value = "Oss上传签名生成")
    @GetMapping(value = "/policy")
    public R<OssPolicyResp> policy() {

        OssPolicyResp result = ossService.policy();
        return R.success(result);
    }

    @PostMapping(value = "callback")
    @ApiOperation(value = "Oss上传成功回调")
    public R<OssCallbackResp> callback(HttpServletRequest request) {

        OssCallbackResp ossCallbackResult = ossService.callback(request);
        return R.success(ossCallbackResult);
    }

}
